// 连接mongodb数据库
const mongoose = require('mongoose')

mongoose.connect('mongodb://127.0.0.1:27017/user')
    .then(() => console.log('数据库连接成功'))
    .catch(err => console.log(err, '数据库连接失败'))

// 创建用户登录数据库集合规则
const userSchema = new mongoose.Schema({
    username: String,
    password: String,
    per: String
})
// 创建订单数据库集合规则
const dingdanSchema = new mongoose.Schema({
    person: String,
    name: String,
    class: String,
    price: String,
    num: String
})
// 创建货物总集合规则
const storeSchema = new mongoose.Schema({
    person: String,
    name: String,
    class: String,
    price: String,
    number: String,
    hj:String,
    weizhi:String
})
// 创建已完成订单集合规则
const finishSchema = new mongoose.Schema({
    person: String,
    name: String,
    class: String,
    price: String,
    num: String
})
// 创建集合
const User = mongoose.model('User', userSchema)
const Dingdan = mongoose.model('Dingdan', dingdanSchema)
const Finish = mongoose.model('Finish', finishSchema)
const Store = mongoose.model('Store', storeSchema)
module.exports = { User, Dingdan, Store, Finish}